<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=`, initial-scale=1.0">
    <title>筛选数组</title>
    <script>
        // 选出大于等于10的元素，放入新数组
        var arr = [2, 0, 6, 1, 77, 0, 52, 0, 25, 7]
        var newArr = []
        var j= 0
        for (i =0; i < arr.length; i++) {
            if (arr[i] >= 10) {
                newArr[j] = arr[i]
                // newArr[newArr.length] = arr[i]  只用一个这种也行
                j++
            }
        }
        console.log(newArr);

        // 将数组中的 0 去掉
        var arr1 = [2, 0, 6, 1, 77, 0, 52, 0, 25, 7]
        var newArr1 = []
        for (var i = 0; i < arr1.length; i++) {
            if (arr1[i] !== 0) {
                newArr1[newArr1.length] = arr1[i]
            }
        }
        console.log(newArr1);
    </script>
</head>
<body>
    
</body>
</html>